When the base image decompressor calls your image decompressor component's ImageCodecDrawBand function, your component must perform the decompression specified by the fields of the ImageSubCodecDecompressRecord structure. The structure includes any changes your component made to it when performing the ImageCodecBeginBand function.
If the ImageSubCodecDecompressRecord structure specifies either a progress function or a data-loading function, the base image decompressor never calls the ImageCodecDrawBand function at interrupt time. If not, the base image decompressor may call the ImageCodecDrawBand function at interrupt time.
If the ImageSubCodecDecompressRecord structure specifies a progress function, the base image decompressor handles codecProgressOpen and codecProgressClose calls, and your image decompressor component must not implement these functions.
If your component supports asynchronous scheduled decompression, it may receive more than one ImageCodecBeginBand call before receiving an ImageCodecDrawBand call.
A sample implementation of ImageCodecDrawBand is shown in Listing 5 .
Listing 5 Sample implementation of ImageCodecDrawBand
pascal ComponentResult ImageCodecDrawBand (
ComponentInstance ci,
ImageSubCodecDecompressRecord *drp)
{
ExampleDecompressRecord *mydrp = drp->userDecompressRecord;
short y;
Ptr cDataPtr = drp->codecData; // compressed data pointer;
Ptr baseAddr = drp->baseAddr; // base address of dest PixMap;
SInt8 mmuMode = true32b; // we want to be in 32-bit mode
OSErr err = noErr;
for (y = 0; y < mydrp->numStrips; y++) {
if (drp->dataProcRecord.dataProc) {
if ( (err =
CallICMDataProc(drp->dataProcRecord.dataProc,&cDataPtr,
mydrp->srcDataIncrement,
drp->dataProcRecord.dataRefCon)) != noErr ) {
err = codecSpoolErr;
goto bail;
}
}
SwapMMUMode(&mmuMode); // put us in 32-bit mode
(mydrp->decompressStripProc)(cDataPtr,baseAddr,(short)drp->rowBytes,
(short)mydrp->width,glob->sharedGlob);
SwapMMUMode(&mmuMode); // put us back
baseAddr += mydrp->baseAddrIncrement;
cDataPtr += mydrp->srcDataIncrement;
if (drp->progressProcRecord.progressProc) {
if ( (err =
CallICMProgressProc(drp->progressProcRecord.progressProc,
codecProgressUpdatePercent,
FixDiv ( y, mydrp->numStrips),
drp->progressProcRecord.progressRefCon)) != noErr ) {
err = codecAbortErr;
goto bail;
}
}
}
bail:
return err;
}
| Previous | Chapter Contents | Chapter Top | Next |